//自定义按钮权限指令
import { Directive } from 'vue'
import { useMenuStore } from '@/store/menu'

export default function useBtnAuth() {

    const menuStore = useMenuStore()

    const permission: Directive = {
        mounted(el, binding) {
            //value按钮上的权限
            const { value } = binding;
            //获取用户所有的权限
            const permissions = menuStore.getAdminAuth
            //判断传递进来的按钮权限，是否存在
            if (permissions.indexOf(String(value)) == -1) {
                console.log(value)
                el.style.display = 'none'
            }
        }
    }

    return { permission }
}
